{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">

                </div>

                <div class="col-sm-12">
                    <div class="input-group" >

                    </div>
                </div>

            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <!--状态显示模板-->
                    <script type="text/html" id="imgTpl">
                        <ul class="aaasss">
                            {{#  layui.each(d.comment_image, function(index, item){ }}
                            <img src="{{item}}" data-original="{{item}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                            {{#  }); }}
                        </ul>
                    </script>
                    {if $contract == 1}
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('查看评论/回复', '{:url('admin/Evaluate/detail')}?comment_id={{d.comment_id}}')" class="btn btn-primary btn-xs m-r-xs" title="查看评论/回复">查看评论/回复</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.comment_id}}','{:url('admin/Evaluate/del')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                        {{# if(!d.comment_reply_content){ }}
                        <a href="javascript:;" onclick="wk.layer_show('查看评论/回复', '{:url('admin/Evaluate/reply')}?report_id={{d.comment_id}}')" class="btn btn-primary btn-xs m-r-xs" title="回复评论"><i class="fa fa-pencil">回复评论</i></a>
                        {{# } }}

                    </script>
                    {else /}
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('查看评论/回复', '{:url('admin/Evaluateps/detail')}?comment_id={{d.comment_id}}')" class="btn btn-primary btn-xs m-r-xs" title="查看评论/回复">查看评论/回复</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.comment_id}}','{:url('admin/Evaluateps/del')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                        {{# if(!d.comment_reply_content){ }}
                        <a href="javascript:;" onclick="wk.layer_show('查看评论/回复', '{:url('admin/Evaluateps/reply')}?report_id={{d.comment_id}}')" class="btn btn-primary btn-xs m-r-xs" title="回复评论"><i class="fa fa-pencil">回复评论</i></a>
                        {{# } }}

                    </script>
                    {/if}
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Order/orderComments")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: false
            , where: {'order_id':{$order_id},'contract':{$contract}}
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type:'numbers', width: 80, title: '序号'}
//                , {field: 'banner_id', width: 80, title: 'ID', align: 'center'}
                {field: 'comment_id', width: '', title: 'ID', align: 'center'}
                ,{field: 'user_username', width: '', title: '评论用户', align: 'center'}
                , {field: 'user_phone', width:'', title: '评论用户电话', align: 'center'}
                , {field: 'comment_star', width:'', title: '评论是几星', align: 'center'}
                , {field: 'comment_content', width:'', title: '评论内容', align: 'center'}
                , {field: 'comment_image', width:'', title: '评论图片', align: 'center', toolbar: '#imgTpl'}
                , {field: 'comment_time', width:'', title: '评论时间', align: 'center'}
                , {field: 'good_name', width:'', title: '商品名字', align: 'center'}
                , {field: 'comment_guige', width:'', title: '商品规格', align: 'center'}
                , {fixed: 'right', width:'300', title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            , done: function (res, curr, count) {
                $('.aaasss').viewer({
                    url: 'data-original'
                });
            }
        });
        //监听单元格编辑
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
            // layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
            var patrn = /^[0-9]*$/;
            if(!patrn.test(value)){
                layer.msg('排序值只能为数字',{icon:2,time:1500,shade: 0.1},function(){
                    //重载当前页表格
                    $(".layui-laypage-btn").click();
                });
                return false;
            }
            wk.changeSort(data.banner_id,"{:url('sort')}",field,value);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量删除
            batchDel:function () {
                wk.batchDel(getIds(),"{:url('del')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['s_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>